extends Base1
@onready var player:CharacterBody2D=$"../.."
@onready var animate:AnimatedSprite2D=$"../../AnimatedSprite2D"

func enter():
	$Timer.stop()
	animate.play("parasite_animation")
	pass

func do():
	var bodies = $"../../AttackCheck".get_overlapping_bodies()
	animate.play("parasite_animation")  # 播放寄生动画
	for body in bodies:
		if body.is_in_group("can_be_parasited"):
	# 假设你已经创建并导入了名为player_hit_enemy_frames的SpriteFrames资源,
		# 假设enemy_frames是敌人的SpriteFrames资源
			var enemy_frames = load("res://人物场景/敌人/"+body.get_enemy_frames()+".tres")
			animate.frames = enemy_frames
			#yield(get_tree().create_timer(1.0), "timeout")  # 假设寄生动画持续1秒
			get_parent().change_state(0)
			break
	pass
func fangda():
	if (animate.scale.y<=2 and animate.scale.x<=2):
		animate.scale.x+=0.01  # 放大
		animate.scale.y+=0.01
		fangda()
	pass


#func _on_parasit_suofang():
	#if (animate.scale.y<=2 and animate.scale.x<=2):
		#print("放大")
		#animate.scale.x+=0.01  # 放大
		#animate.scale.y+=0.01
	#if (animate.scale.y>=1):
		#print("缩小")
		#animate.scale.x-=0.01  # 放大
		#animate.scale.y-=0.01
	#pass

